#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using EstateNuke.Data;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;

#endregion

namespace EstateNuke.BusinessSystem.Controls.EstateControls
{
    public partial class BuildingViewControl : UserControl
    {
        private Building _currentBuilding;
        private RoomOperationType _roomOperationType;
        public BuildingViewControl(Building building, RoomOperationType type)
        {
            _currentBuilding = building;
            _roomOperationType = type;

            InitializeComponent();
        }

        private void BindBuilding()
        {
            int width = 0;
            if (_currentBuilding != null)
            {
                foreach (var entrance in _currentBuilding.Entrances.OrderBy(c=>c.Number))
                {
                    EntranceViewControl control = new EntranceViewControl(entrance, _currentBuilding, _roomOperationType);
                    width += control.Width;
                    flpRoomContainer.Controls.Add(control);
                }
            }
            flpRoomContainer.Width = width;
            flpRoomContainer.Height = _currentBuilding.Floors.Count * (Constant.ViewRoomHeight + 4) + 50;
            this.Height = flpRoomContainer.Height;
            this.Width = flpRoomContainer.Width;
        }

        private void BuildingViewControl_Load(object sender, EventArgs e)
        {
            BindBuilding();
        }
    }
}